﻿using ShopPowerTemplate.Common;
using ShopPowerTemplate.Entities;
using ShopPowerTemplate.WebServiceReference;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Imaging;

namespace ShopPowerTemplate.ViewModels
{
    public class ImagePresenterViewModel : BindableBase
    {
        Image image = null;
        public Image Image
        {
            get { return this.image; }
            set
            {
                if (this.SetProperty(ref this.image, value))
                    InitializeImage();
            }
        }

        private BitmapImage bitmapImage;
        public BitmapImage BitmapImage
        {
            get { return bitmapImage; }
            set { this.SetProperty(ref bitmapImage, value); }
        }

        public ImagePresenterViewModel(Image image)
        {
            Image = image;
        }

        private async void InitializeImage()
        {
            BitmapImage = await ZipHelper.ExtractImage(Image.Data);
        }
    }
}
